package learn_fream

import (
	"github.com/gogf/gf/v2/net/ghttp"
	"go_fream/internal/service"
)

type LearnHtml struct {
}

func NewLearnHtml() *LearnHtml {
	return &LearnHtml{}
}

func (c *LearnHtml) Tpl(req *ghttp.Request) {
	books, err := service.Book().GetList(req.Context())
	if err != nil {
		req.Response.Writeln("发生错误： " + err.Error())
	}
	req.Response.WriteJson(books)
}

func (c *LearnHtml) TplFirst(req *ghttp.Request) {
	html := `<!DOCTYPE html>
    <html lang="zh">
	<head>
    	<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>Document</title>
    </head>
    <body>
		<ul>
			<li>姓名： %s</li>
			<li>性别： %s</li>
			<li>年龄： %s</li>
		</ul>
    </body>
	</html>`

	req.Response.Writef(html, "林冲", "男", 35)
}
